import 'package:get/get.dart';

import 'classroom_state.dart';

/// 课堂逻辑控制器 - Classroom Logic Controller
/// 
/// 管理课堂页面的状态和业务逻辑
/// Manages the state and business logic of the classroom page
class ClassroomLogic extends GetxController {
  final Rx<ClassroomState> state = ClassroomState(
    isLoading: false,
    courses: ['命理入门', '十神详解', '五行与性格'],
    errorMessage: null,
  ).obs;

  @override
  void onInit() {
    super.onInit();
    loadCourses();
  }

  /// 加载课程列表 - Load courses list
  void loadCourses() {
    state.value.isLoading = false;
    state.value.courses = [
      '命理入门',
      '十神详解',
      '五行与性格',
      '八字排盘',
      '紫微斗数',
      '奇门遁甲',
    ];
    state.value.errorMessage = null;
  }

  /// 处理课程点击 - Handle course tap
  void onCourseTap(String courseName) {
    Get.snackbar(
      '课程详情',
      '$courseName 课程详情页面正在开发中',
      snackPosition: SnackPosition.BOTTOM,
    );
  }
}
